package com.project.util;

import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;

public class Verifier {
    public static String verifierJwt(String token) {
        //私钥及加密算法
        Algorithm algorithm = Algorithm.HMAC256(CreateToken.TOKEN_SECRET);
        String info = "";
        JWTVerifier verifier = JWT.require(algorithm).build();
        try {
            DecodedJWT jwt = verifier.verify(token); //认证token
            info = jwt.getClaim("info").asString();//取token中的信息
        } catch (Exception e) {
            return info;
        }
        return info;
    }
}
